
#ifndef MATRIX_H
#define MATRIX_H
class matrix
{
private:
	double a, b, c, d;
public:
	matrix()
	{
		a = 1;
		b = 0;
		c = 0;
		d = 1;
	}
	explicit matrix(double m, double n, double p, double i) :a(m), b(n), c(p), d(i)
	{}
	friend ostream& operator<<(ostream& os, const matrix& m);
	friend istream& operator>>(istream& is,matrix& m);
	matrix operator+(const matrix &m)const
	{
		matrix n;
		n.a = a + m.a;
		n.b = b + m.b;
		n.c = c + m.c;
		n.d = d + m.d;
		return n;
	}
	matrix operator-(const matrix& m)const
	{
		matrix n;
		n.a = a - m.a;
		n.b = b - m.b;
		n.c = c - m.c;
		n.d = d - m.d;
		return n;
	}
	matrix operator*(const matrix& m)const
	{
		matrix n;
		n.a = a* m.a+b*m.c;
		n.b = a* m.b+b*m.d;
		n.c = c* m.a+d*m.c;
		n.d = c* m.b+d*m.d;
		return n;
	}
	friend matrix operator*(double i, const matrix& m);
	matrix operator+=(const matrix& m)const
	{
		matrix n;
		n.a = a + m.a;
		n.b = b + m.b;
		n.c = c + m.c;
		n.d = d + m.d;
		return n;
	}
	matrix operator-=(const matrix& m)const
	{
		matrix n;
		n.a = a - m.a;
		n.b = b - m.b;
		n.c = c - m.c;
		n.d = d - m.d;
		return n;
	}
	matrix operator*=(const matrix& m)const
	{
		matrix n;
		n.a = a * m.a + b * m.c;
		n.b = a * m.b + b * m.d;
		n.c = c * m.a + d * m.c;
		n.d = c * m.b + d * m.d;
		return n;
	}
	matrix operator*=(double i)
	{
		matrix n;
		n.a = a * i;
		n.b = b * i;
		n.c = c * i;
		n.d = d * i;
		return n;
	}
	bool operator==(const matrix& m)const
	{
		if (a == m.a && b == m.b && c == m.c && d == m.d)return 1;
		else return 0;
	}
	bool operator!=(const matrix& m)const
	{
		if (a != m.a || b != m.b || c != m.c || d != m.d)return 1;
		else return 0;
	}
};
ostream& operator<<(ostream& os, const matrix& m);
istream& operator>>(istream& is, const matrix& m);
matrix operator*(double i, const matrix& m);
#endif